<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../css/buttons.css" />
		<link rel="stylesheet" type="text/css" href="../js/easyui/themes/icon.css">
		<link rel="stylesheet" type="text/css" href="../js/easyui/themes/black/easyui.css">
		<script type="text/javascript" src="../js/easyui/jquery.min.js"></script>
		<script type="text/javascript" src="../js/easyui/jquery.easyui.min.js"></script>
		<script type="text/ecmascript" src="../js/easyui/locale/easyui-lang-zh_CN.js"></script>
		<script type="text/javascript">
			var userId = window.localStorage.getItem("uid"); //获取登录页面中暂时存储的数据
			var roleNames = window.localStorage.getItem("roleNames");
			var token = window.sessionStorage.getItem("token");

			//点击修改表单的取消按钮

			//安全推出
			function exit() {
				window.localStorage.clear("roleNames");
				top.location = "../login.html"
			}
			
			
			/*清除表单中的内容*/
			function closeUserForm() {
				$("#updatepasswordForm").form("clear");
			}

			function submitupdateUserForm() {
				var oldpassword = $("#oldpassword").val();
				var password = $("#password").val();
				var doupassword = $("#doupassword").val();

				if(password == doupassword) {
					$.post(
						"http://localhost:8080/CRM/user/updatepassword", {
							roleNames: roleNames,
							Id: userId,
							oldpassword: oldpassword,
							password: password,
							token: token

						},
						function(res) {
							if(res.success) {
								$.messager.alert("提示","修改成功")
								$.messager.alert("提示","您修改的新密码是:" + password + "已经发至您的邮箱!!  快夸夸我", "info",function(){
									exit();
								})
								
								$("#updatepassword_window").window("clear");
								
							} else {
								alert(res.remark)
							}
						}, "json");

				} else {
					$.messager.alert("提示","两次密码输入一致")
					closeUserForm();
				}

			}
		</script>

	</head>

	<body>

		<div id="updatepassword_window" class="easyui-window" title="修改自己的密码信息" data-options="modal:true,iconCls:'icon-save'" style="width:500px;height:300px;padding:10px;">
			<form id="updatepasswordForm">
				<table cellpadding="5" style="padding-top: 30px; padding-left: 60px;">
					<tr>
						<td>原密码:</td>
						<td><input class="easyui-textbox" type="password" name="oldpassword" id="oldpassword" data-options="required:true"></input>
						</td>
					</tr>

					<tr>
						<td>新密码:</td>
						<td><input class="easyui-textbox" type="password" name="password" id="password" data-options="required:true"></input>
						</td>
					</tr>

					<tr>
						<td>再次输入新密码:</td>
						<td><input class="easyui-textbox" type="password" name="doupassword" id="doupassword" data-options="required:true"></td>
					</tr>
				</table>
			</form>
			<div style="text-align:center;padding:5px">
				<a href="javascript:void(0)" class="easyui-linkbutton" type="button" onclick="submitupdateUserForm()">保存</a>
				<a href="javascript:void(0)" class="easyui-linkbutton" onclick="closeUserForm()">取消</a>
			</div>
		</div>

	</body>

</html>